package com.space.product;

import com.space.client.api.ProductService;
import com.space.client.dto.ProductInfoDTO;
import com.space.components.exception.catcher.ExceptionCatcher;
import com.space.components.response.SingleResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;


/**
 * Controller
 *
 * @author Bedroom
 */
@Api(tags= "产品相关接口",value = "提供产品相关的 Rest API")
@RestController
@ExceptionCatcher
@RequestMapping("/product")
public class ProductController {
    @Autowired
    ProductService productService;

    @ApiOperation(value= "查找产品接口",notes = "根据产品id查找产品信息")
    @RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
    public Mono<SingleResponse<ProductInfoDTO>> getProductInfo(
            @ApiParam(name= "id",value = "产品id",required = true) @PathVariable Integer id
    ) {
        return productService.getProductInfo(id).map(SingleResponse::of);
    }
}
